package model;

import toolkit.Debug;

public enum CardRank {
	
	TWO(2), THREE(3), FOUR(4), FIVE(5), SIX(6),SEVEN(7), EIGHT(8), NINE(9), TEN(10),
	
	JACK(11), QUEEN(12), KING(13), ACE(14);
	
	public final static int MIN_INTEGER_VALUE = 1;
	
	public final static int MAX_INTEGER_VALUE = 14;
	
	private final int value;
	
	private CardRank(int value)
	{
		this.value = value;
	}
	
	public static CardRank valueOf(int value)
	{
		if (value >= 2 && value <= 14)
		{
			return CardRank.values()[value - 2];
		}
		else if (value == 1)
		{
			return ACE;
		}
		
		return null;
	}
	
	public boolean equals(int value)
	{
		if (this == ACE && value == 1)
		{
			return true;
		}
		
		return value == this.value;
	}

	public int toInteger()
	{
		return value;
	}

	public String toShortString()
	{
		if (value >= 2 && value <= 10)
		{
			return "" + value;
		}
		else
		{
			switch (this)
			{
				case ACE:
					
					return "a";
				
				case JACK:
					
					return "j";
				
				case QUEEN:
					
					return "q";
				
				case KING:
					
					return "k";
			}
		}
		
		return "?";
	}
	
	public String toString()
	{
		if (value >= 2 && value <= 10)
		{
			return Integer.toString(value);
		}
		else
		{
			switch (this)
			{
				case ACE:
					
					return "Ace";
				
				case JACK:
					
					return "Jack";
				
				case QUEEN:
					
					return "Queen";
				
				case KING:
					
					return "King";
			}
		}
		
		return null;
	}
}
